package com.jsmy.softapp.util;

import android.content.Context;
import android.content.pm.PackageManager;

/**
 * Created with Android Studio.
 * User: wei_cd.
 * Date: 2018/4/26.
 * Time: 14:24.
 * To change for file | settings | file and code templates.
 */

public class VersionUtil {

    /**
     * // 获取软件版本号 versionCode
     * @param context
     * @return
     */
    public static int getVersionCode(Context context) {
        int versionCode = 0;
        try {

            versionCode = context.getPackageManager().getPackageInfo("com.jsmy.softapp", 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionCode;
    }

    /**
     * // 获取软件版本号 versionName
     * @param context
     * @return
     */
    public static String getVersionName(Context context) {
        String versionCode = "";
        try {

            versionCode = context.getPackageManager().getPackageInfo("com.jsmy.softapp", 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionCode;
    }
}
